package models.entities;

import com.google.gson.annotations.Expose;

import javax.persistence.Transient;
import java.awt.image.BufferedImage;
import java.io.File;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

public class ProductEntity {
    @Expose
    public Integer id;

    public String title;

    public List<Integer> imagesIds;

    public File image;

    public int defaultImageId;

    public String description;

    public double price;

    public String distributorId;

    public int categoryId;

    public int brandId;
    @Expose
    public int createdByUserId;
    public String brandName;
    public String categoryTitle;
    public double discountPrice;
    public String shortDescription;
    public int imagesCount;
    public String priceString;
    //TODO: set this value from DB
    public boolean hasPicture;
    public List<String> pictureUrls = new ArrayList<String>();
    public List<ProductSourceEntity> productSources;
    public List<BufferedImage> picturesData = new ArrayList<BufferedImage>();
    public BufferedImage brandImage;
    public String brandImageUrl;


    public boolean isHasPicture() {
        return imagesCount > 0;
    }

    @Transient
    public String getPriceString() {
        NumberFormat formatter = new DecimalFormat("#.##");
        //TODO: remove this hard-code
        return formatter.format(price) + " р.";
    }
}
